/*
 * Copyright © 2015-2019 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

@import '../styles/variables.less';
@import "../../node_modules/@bower_components/bootstrap/less/mixins.less";
@import '../styles/themes/cdap/mixins.less';

body.theme-cdap.state-hydrator {
  &.state-hydrator-detail {
    background-color: @table-bg;

    my-dag-plus .my-js-dag {
      border-bottom: 0;
    }

    div.console {
      div.console-tabs ul.nav-tabs li {
        margin-bottom: -1px;
      }
      div.console-type {
        // Avoid unnecessary horizontal scroll
        overflow-x: hidden;
        padding: 0;
        width: 100%;
        .p-10 {
          padding: 10px;
        }
        button.btn-grey { margin-top: 10px; }
      }
      div.bottompanel-body {
        width: 100%;
      }
      .history-table .table {
        border: 1px solid #dddddd;
      }
      .table {
        th {
          height: 30px;
          padding: 0 5px;
          vertical-align: middle;
        }
        // Metrics view
        td.metric-cell {
          padding: 0;
        }
        &.metric-table {
          tr {
            &:first-child > td {
              border-top: 0;
            }

            &:last-child > td {
              border-bottom: 0;
            }
          }
          td {
            &:first-child {
              border-left: 0;
            }
            &:last-child {
              border-right: 0;
            }
          }
        }
      }
      select.cron-select:hover {
        cursor: not-allowed;
      }
      &.maximized {
        top: 93px;
      }
    }
  }

  div.console {
    @media (min-height: 800px) {
      min-height: ~"-moz-calc(60vh - 113px)";
      min-height: ~"-webkit-calc(60vh - 113px)";
      min-height: ~"calc(60vh - 113px)";
    }

    background-color: white;
    position: relative;
    width: 100%;
    min-height: ~"-moz-calc(40vh - 113px)";
    min-height: ~"-webkit-calc(40vh - 113px)";
    min-height: ~"calc(40vh - 113px)";
    z-index: 999;
    transition: height 0.2s ease;

    // Styling for minimized bottom panel
    &.minimized {
      position: fixed;
      right: 0;
      bottom: 53px;
      min-height: 0;
      z-index: 999;

      .console-type {
        display: none;
        height: 0;
        min-height: 0;
      }
    }
    &:not(.minimized) {
      span.badge {
        position: relative;
      }
    }
    // Styling for maximized bottom panel
    &.maximized {
      position: fixed;
      right: 0;
      left: 0;
      bottom: 53px;
      overflow-y: scroll;
      overflow-x: hidden;
      z-index: 999;
      div.console-tabs {
        border-top: 0;
      }

      .post-actions-tab {
        .post-actions-sidebar {
          top: 41px;
        }
      }
    }
  }

  // When bottom panel is in minimized state, set width based on left panel state
  div.left-panel-wrapper {
    ~ .right-wrapper div.console:not(.maximized) {
      width: ~"-moz-calc(100vw - 130px)";
      width: ~"-webkit-calc(100vw - 130px)";
      width: ~"calc(100vw - 130px)";
      transition: width 0.2s ease;
    }
    &.expanded ~ .right-wrapper div.console:not(.maximized) {
      width: ~"-moz-calc(100vw - 290px)";
      width: ~"-webkit-calc(100vw - 290px)";
      width: ~"calc(100vw - 290px)";
    }
  }

  div.console-tabs {
    background-color: @body-bg;
    border-top: 1px solid @table-border-color;
    position: relative;
    ul.nav-tabs {
      border-bottom: 0;
      li {
        margin-bottom: 0;
        border-radius: 0;
        border: 0;
        border-bottom: 1px solid @body-bg;
        color: #666666;
        font-weight: 500;
        line-height: inherit;
        margin-right: 0;
        padding: 10px 15px;
        transition: all 0.2s ease;
        &:hover,
        &:focus {
          background-color: transparent;
          border: 0;
          border-bottom: 2px solid transparent;
          cursor: pointer;
        }
        &.bg-danger {
          background-color: fade(@brand-danger, 40%);
        }
        &.bg-success {
          background-color: fade(@brand-success, 40%);
        }
        &.bg-primary {
          background-color: fade(@brand-primary, 40%);
        }
        &.active {
          border-bottom: 2px solid var(--brand-primary-color);
        }
        .badge {
          display: inline;
          margin-left: 5px;
        }
      }
    }
    > div {
      margin: 0 10px;
      a {
        color: @brand-primary;
        cursor: default;
        display: inline-block;
        padding: 10px;
        transition: all 0.2s ease;
        &:hover,
        &:focus {
          color: var(--brand-primary-color);
          cursor: pointer;
        }
      }
    }
  }
  .form-input-attr {
    padding-right: 0;

    &.col-xs-11 {
      padding-left: 100px;
    }
    .highlight-error {
      border: 1px solid #d15668;
      border-radius: 4px;
    }
  }

  .info-attr {
    padding-left: 5px;
  }
  div.console-type {
    border-top: 1px solid @table-border-color;
    h4 {
      color: #666666;
      font-size: 14px;
      font-weight: 500;
      margin-top: 0;
    }
    .plugin-group-description {
      color: @grey-03;
    }
    .field-header {
      &.subtitle {
        color: #999999;
        border-bottom: 1px solid #666666;
        clear: both;
        width: 100%;
        margin-bottom: 0;
        display: flex;
        align-items: center;

        h4 {
          display: inline-block;
          background-color: #ffffff;
          padding-right: 5px;
          font-size: 16px;
          font-weight: bold;
          margin-bottom: 4px;
        }
      }
    }

    .select-wrapper {
      .select-wrapper(transparent);
    }

    fieldset {
      width: 100%;
      .widget-group-container {
        a.btn {
          padding-right: 6px;
          padding-left: 6px;
        }
        &.well .form-group {
          margin-bottom: 10px;
        }

        &.no-config {
          .macro-indicator-container {
            line-height: 32px;

            .macro-indicator {
              color: @hydrator-blue;
              transform: scale(0.7);

              .icon-M {
                line-height: inherit;
              }
            }
          }
        }
      }
      .panel-body {
        min-height: 50px;
      }
    }
    .sink-output-schema {
      .output-schema {
        margin-top: 20px;
      }
    }
    .old-output-schema-container {
      padding-bottom: 10px;
    }
    .output-schema {
      height: 100%;
      .schema-propagation-confirm {
        padding-top: 10px;
      }
      .confirmation-button {
        margin-top: 5px;
      }
      .btn-group {
        .btn {
          margin-right: 5px;
        }
      }
    }
    plugin-schema-editor {
      height: 100%;
      display: block;
    }
    .input-schema {
      height: 100%;
      .schema-inner {
        height: 100%;
      }
      @media (max-width: @screen-md-max) {
        margin-bottom: 15px;
      }
    }
    .schema-error ul:only-child {
      margin-bottom: 0;
    }
    .schema-inner > textarea {
      height: auto;
      resize: vertical;
    }
    .table {
      background-color: transparent;
      margin: 0;
      th,
      td {
        max-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      th {
        border: 0;
        padding: 0;

        label {
          margin-bottom: 0;
          vertical-align: top;
        }
      }
      td {
        border: 1px solid @table-border-color;
        border-collapse: collapse;
        height: 36px;
        padding: 0 5px;
        vertical-align: middle;
        div.select-wrapper:after {
          right: 5px;
        }
        select.form-control {
          padding-right: 20px;
        }
        &.nullable {
          width: 35px;
        }
        &.trash {
          width: 35px;
          a {
            padding-left: 0;
            padding-right: 0;
          }
          .btn:active { box-shadow: none; }
        }
      }
      &.table-curved {
        tr:first-child {
          td {
            border-top: 0;
            &:first-child { border-radius: 8px 0 0 0; }
            &:last-child { border-radius: 0 8px 0 0; }
          }
        }
        td {
          border-width: 1px 0 0 1px;
        }
      }
      .control-label {
        font-size: 13px;
      }
      .form-control {
        border: 0;
        padding: 0;
      }

      input {
        &[type="text"] {
          padding-left: 5px;
        }
        &[type="checkbox"] {
          margin: 0;
        }
      }
      .fa-trash {
        color: @brand-danger;
        font-size: 15px;
      }
    }
    .form-control {
      box-shadow: none;
      &:focus {
        border-color: @table-border-color;
        outline: 1px solid @hydrator-blue;
        box-shadow: none;
      }
    }
    td.active-cell {
      input:focus,
      select:focus {
        outline: 0;
      }
    }
    .loading-message {
      margin-left: 10px;
    }
    .bottompanel-header {
      border-bottom: 1px solid @table-border-color;
      padding: 10px;
      > div:first-child {
        max-width: 80%;
      }
      h3 {
        color: @gray-dark;
        font-size: 16px;
        font-weight: 500;
        margin: 0 0 5px;
      }
      p {
        color: #9d9d9d;
        margin-bottom: 0;
      }
      .btn-group {
        > div {
          display: inline-block;
        }
      }
    }
    .bottompanel-body {
      padding: 20px 10px;

      .engine-panel {
        padding-left: 20px;

        label {
          font-weight: 500;
          line-height: 21px;
        }
        h2 {
          margin-top: 0;
          .fa.fa-info-circle {
            vertical-align: middle;
            font-size: 16px;
          }

          .popover {
            border-radius: 0;
            background: #333333;
            color: white;

            .popover-content {
              padding-top: 5px;
            }
            .arrow {
              border-right-color: #333333;
              &:after {
                border-right-color: #333333;
              }
            }
          }
        }
        form {
          margin: 15px 0 0 20px;

          label {
            &:not(:first-child) {
              margin-top: 10px;
            }
          }
        }
      }
      .empty-hidden-properties-message {
        margin: 0 0 5px 0;
      }

      .label-input-container {
        padding: 10px;

        // to keep consistent with the rest of ConfigurationGroup
        width: calc(100% - 40px);
      }

      .config-table {
        form[plugin-property-edit-view] {
          .form-group {
            display: flex;
            align-items: center;

            .control-label {
              padding-top: 0;
              padding-right: 0;
            }
            .form-input-attr {
              position: relative;
              padding-right: 0;
            }
            ul.validation-errors-list {
              list-style-position: inside;
              > li {
                padding: 0;
              }
            }
          }
        }
      }
    }
    .action-table {
      form[plugin-property-edit-view] {
        .form-input-attr {
          &.code-editor {
            @media (min-width: 1200px) {
              padding-left: 200px;
            }
            @media (min-width: 1800px) {
              padding-left: 300px;
            }
            @media (min-width: 2400px) {
              padding-left: 400px;
            }
          }
        }
      }
    }
    .post-actions-detail,
    .post-actions-tab {
      .table {
        th,
        td {
          padding: 10px;
          font-size: 13px;
          font-weight: 500;
        }

        th {
          border: 1px solid #dddddd;
          cursor: default;
        }

        td {
          color: #999999;
          &:first-child { width: 200px; }
          &:nth-child(3) { width: 200px; }
          &:last-child {
            width: 80px;
            a { color: @hydrator-blue; }
            i { cursor: pointer; }
          }
        }
      }
    }

    .post-actions-tab {
      .post-actions-sidebar {
        width: 150px;
        border-right: 1px solid #d4d4d4;
        background-color: #eeeeee;
        position: absolute;
        top: 42px;
        bottom: 0;

        ul {
          li {
            height: 40px;
            line-height: 40px;
            font-weight: 500;
            color: #999999;
            cursor: pointer;
            border-bottom: 1px solid #d4d4d4;
            padding-left: 15px;

            &.active {
              background-color: white;
              color: @hydrator-blue;

              // this 1px will cover the sidebar border
              width: ~"-moz-calc(100% + 1px)";
              width: ~"-webkit-calc(100% + 1px)";
              width: ~"calc(100% + 1px)";
            }
          }
        }
      }

      .post-actions-content {
        width: ~"-moz-calc(100% - 151px)";
        width: ~"-webkit-calc(100% - 151px)";
        width: ~"calc(100% - 151px)";
        float: right;
        min-height: 40vh;

        .main-container {
          padding: 10px 20px 10px 10px;

          .empty-message {
            margin-top: 100px;
            margin-bottom: 100px;
          }

          .action-buttons {
            button {
              margin-left: 15px;
              width: 80px;
            }
          }
        }
      }
    }

    pre {
      background-color: transparent;
      border: 0;
      display: inline;
      padding: 0;
      white-space: pre-wrap;
      &:after {
        display: block;
        content: '';
        margin-bottom: 10px;
      }
    }
  }
  // Place bottom panel tooltips (Minimize, Maximize, etc.) at the top of the stacking order
  .tooltip.tooltip-pane {
    z-index: 9999;
  }
  footer.app-footer {
    // Creates a bottom border for the bottom panel, needed to accommodate the single scroll
    border-top: 1px solid @table-border-color;
    position: fixed;
    z-index: 999;
  }
}
